<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="mailbox-mmdf.html" />
<link rel="prev" href="mailbox-mh.html" />
<link rel="parent" href="mailbox-objects.html" />
<link rel="next" href="mailbox-mmdf.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>7.3.1.4 Babyl</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.3.1.3 MH"
  href="mailbox-mh.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="7.3.1 mailbox objects"
  href="mailbox-objects.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7.3.1.5 MMDF"
  href="mailbox-mmdf.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="mailbox-mh.html">7.3.1.3 MH</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="mailbox-objects.html">7.3.1 Mailbox objects</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="mailbox-mmdf.html">7.3.1.5 MMDF</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h3><a name="SECTION009314000000000000000"></a>
<a name="mailbox-babyl"></a>
<br>
7.3.1.4 <tt class="class">Babyl</tt>
</h3>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-1399' xml:id='l2h-1399' class="class">Babyl</tt></b>(</nobr></td>
  <td><var>path</var><big>[</big><var>, factory=None</var><big>[</big><var>, create=True</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A subclass of <tt class="class">Mailbox</tt> for mailboxes in Babyl format. Parameter
<var>factory</var> is a callable object that accepts a file-like message
representation (which behaves as if opened in binary mode) and returns a custom
representation. If <var>factory</var> is <code>None</code>, <tt class="class">BabylMessage</tt> is used
as the default message representation. If <var>create</var> is <code>True</code>, the
mailbox is created if it does not exist.
</dl>

<p>
Babyl is a single-file mailbox format used by the Rmail mail user agent
included with Emacs. The beginning of a message is indicated by a line
containing the two characters Control-Underscore
("<tt class="character">\037</tt>") and Control-L ("<tt class="character">\014</tt>").
The end of a message is indicated by the start of the next message or, in the
case of the last message, a line containing a Control-Underscore
("<tt class="character">\037</tt>") character.

<p>
Messages in a Babyl mailbox have two sets of headers, original headers and
so-called visible headers. Visible headers are typically a subset of the
original headers that have been reformatted or abridged to be more attractive.
Each message in a Babyl mailbox also has an accompanying list of <i class="dfn">labels</i>,
or short strings that record extra information about the message, and a list of
all user-defined labels found in the mailbox is kept in the Babyl options
section.

<p>
<tt class="class">Babyl</tt> instances have all of the methods of <tt class="class">Mailbox</tt> in addition
to the following:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1400' xml:id='l2h-1400' class="method">get_labels</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return a list of the names of all user-defined labels used in the mailbox.
<span class="note"><b class="label">Note:</b>
The actual messages are inspected to determine which labels exist in the
mailbox rather than consulting the list of labels in the Babyl options section,
but the Babyl section is updated whenever the mailbox is modified.</span>
</dl>

<p>
Some <tt class="class">Mailbox</tt> methods implemented by <tt class="class">Babyl</tt> deserve special
remarks:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1401' xml:id='l2h-1401' class="method">get_file</tt></b>(</nobr></td>
  <td><var>key</var>)</td></tr></table></dt>
<dd>
In Babyl mailboxes, the headers of a message are not stored contiguously with
the body of the message. To generate a file-like representation, the headers
and body are copied together into a <tt class="class">StringIO</tt> instance (from the
<tt class="module">StringIO</tt> module), which has an API identical to that of a file. As a
result, the file-like object is truly independent of the underlying mailbox but
does not save memory compared to a string representation.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1402' xml:id='l2h-1402' class="method">lock</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
<dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1403' xml:id='l2h-1403' class="method">unlock</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>Three locking mechanisms are used--dot locking and, if available, the
<tt class="cfunction">flock()</tt> and <tt class="cfunction">lockf()</tt> system calls.
</dl>

<p>
<div class="seealso">
  <p class="heading">See Also:</p>

<dl compact="compact" class="seeurl">
    <dt><a href='http://quimby.gnus.org/notes/BABYL'
        >Format of Version 5 Babyl Files</a></dt>
    <dd>A
specification of the Babyl format.</dd>
  </dl>
<dl compact="compact" class="seeurl">
    <dt><a href='http://www.gnu.org/software/emacs/manual/html_node/Rmail.html'
        >Reading
Mail with Rmail</a></dt>
    <dd>The Rmail manual, with some information on Babyl semantics.</dd>
  </dl>
</div>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.3.1.3 MH"
  href="mailbox-mh.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="7.3.1 mailbox objects"
  href="mailbox-objects.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7.3.1.5 MMDF"
  href="mailbox-mmdf.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="mailbox-mh.html">7.3.1.3 MH</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="mailbox-objects.html">7.3.1 Mailbox objects</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="mailbox-mmdf.html">7.3.1.5 MMDF</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
